package ua.com.stormlabs.tiny.licenseserver.beans;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.jetbrains.annotations.Nullable;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;

/**
 * @author Maxim Bondarenko
 * @version 1.0 7/4/11
 */

@XStreamAlias("userDetails")
public class User {
    @NotNull
    @Size(min = 5, max = 20, message = "Name length must be between 5 and 20 characters")
    private String userName;

    @NotNull
    @DateTimeFormat(style = "S-")
    private Date expireDate;

    @NotNull
    @DateTimeFormat(style = "S-")
    private Date createDate;

    @NotNull
    private String licenseCode;

    private int id;

    @Nullable
    private String mac;

    @NotNull
    private boolean macChecking;

    private int licenseType;

    private String licenseName;

    @Nullable
    public String getMac() {
        return mac;
    }

    public void setMac(@Nullable String mac) {
        this.mac = mac;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Date getExpireDate() {
        return expireDate;
    }

    public void setExpireDate(Date expireDate) {
        this.expireDate = expireDate;
    }

    public String getLicenseCode() {
        return licenseCode;
    }

    public void setLicenseCode(String licenseCode) {
        this.licenseCode = licenseCode;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public int getLicenseType() {
        return licenseType;
    }

    public void setLicenseType(int licenseType) {
        this.licenseType = licenseType;
    }

    public String getLicenseName() {
        return licenseName;
    }

    public void setLicenseName(String licenseName) {
        this.licenseName = licenseName;
    }

    public boolean getMacChecking() {
        return macChecking;
    }

    public void setMacChecking(boolean macChecking) {
        this.macChecking = macChecking;
    }

    public void setLicense(String licenseName, int licenseType) {
        this.licenseName = licenseName;
        this.licenseType = licenseType;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }
}
